Claim 6 Count the total number of neuron fragments individually labeled in the volume
In [1]:
import numpy as np
import ndio.remote.neurodata as nd
from datetime import datetime
startTime = datetime.now()
oo = nd()
token = 'kasthuri2015_ramon_v1'
channel = 'neurons'
res = 3
pixel_dim = 0.024*0.024*0.030 #can get from LIMS
In [2]:
import ndio.ramon as ramon
# Don't count all objects, because RAMONNeuron paint is already counted in RAMONSegments
# Segments in cylinder
segment_ids_cyl = oo.get_ramon_ids(token, channel, ramon_type=ramon.RAMONSegment)
# Segments in volume are not RAMONified, so doing the hard way
# TODO - RAMONIFY
token = 'kat11segments'
channel = 'annotation'
res = 3
image_size = oo.get_token_info(token)['dataset']['imagesize'][str(res)]
unique_count = []
for i in range(1, image_size[2]+1, 16): #TODO hardcoded z
print str(i).zfill(4),
z_start = i
z_stop = np.min([image_size[2]+1, i + 16])
im = oo.get_volume(token, channel, 0, image_size[0], 0, image_size[1], z_start, z_stop, resolution=res)
unique_count = np.concatenate([np.ravel(unique_count),np.ravel(np.unique(im.cutout))])
segment_ids_all = np.shape(np.unique(unique_count))[0] - 1 #remove 0 label
print datetime.now() - startTime
In [3]:
print 'Segments in cylinder: ' + str(np.shape(segment_ids_cyl)[0]) + ' Total segments: ' + str(segment_ids_all)